package com.cqupt.scanning.system.admin.controller;


import com.cqupt.scanning.system.admin.entity.Department;
import com.cqupt.scanning.system.admin.entity.Organization;
import com.cqupt.scanning.system.admin.entity.vo.DeviceVO;

import com.cqupt.scanning.system.admin.service.DepartmentService;
import com.cqupt.scanning.system.admin.service.OrganizationService;
import com.cqupt.scanning.system.utils.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 宋宝梁
 * @since 2021-07-06
 */
@RestController
@RequestMapping("/admin/organization/department")
public class DepartmentController {

    private DepartmentService departmentService;


    @Autowired
    public DepartmentController(DepartmentService departmentService) {

        this.departmentService = departmentService;
    }

    /**
     * 新增部门(科室)
     * @param department
     * @return
     */
    @PostMapping("/insert")
    @PreAuthorize("hasAuthority('department.insert')")
    public R insert(@RequestBody Department department) {
        return departmentService.insert(department);
    }

    /**
     * 通过机构id逻辑删除科室
     * @param depId
     * @return
     */
    @DeleteMapping("/remove/{id}")
//    @PreAuthorize("hasAuthority('department.delete')")
    public R removeById(@PathVariable("id") Integer depId) {
        return departmentService.delById(depId);
    }
}

